from urllib.request import urlopen

url = 'http://www.baidu.com'

html = urlopen(url)
with open("baidu.html","w",encoding='utf-8') as f:
    f.write(html.read().decode("utf-8"))